Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix zoom to cursor #206

Merged
merged 2 commits into from
Mar 14, 2024
Merged

Fix zoom to cursor #206

merged 2 commits into from
Mar 14, 2024

Conversation

ghsteff
Copy link
Contributor

@ghsteff ghsteff commented Mar 14, 2024

PR Checklist

Please check if your PR fulfills the following requirements:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)

PR Type

What kind of change does this PR introduce?

[x] Bugfix
[ ] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

The camera only zooms towards the center of the graph

Issue Number: #200

What is the new behavior?

When zooming with your mousewheel, the camera zooms towards the cursor

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

This switches mouse wheel behavior to dolly instead of zoom

This allows the dollyToCursor prop to do its thing

Screen.Recording.2024-03-14.at.9.53.13.AM.mov

This switches mouse wheel behavior to dolly instead of zoom

This allows the dollyToCursor prop to do its thing
@@ -224,7 +224,7 @@ export const CameraControls: FC<
} else {
cameraRef.current.mouseButtons.left = 2;
cameraRef.current.mouseButtons.middle = 2;
cameraRef.current.mouseButtons.wheel = 16;
cameraRef.current.mouseButtons.wheel = ThreeCameraControls.ACTION.DOLLY;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is the same as cameraRef.current.mouseButtons.wheel = 8, but I figured this was clearer

could also update the above to

cameraRef.current.mouseButtons.left = ThreeCameraControls.ACTION.TRUCK;
cameraRef.current.mouseButtons.middle = ThreeCameraControls.ACTION.TRUCK;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets do that.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh also just found a bug where the camera's not disabled when disabled is true

I have a little fix, lmk if I should push it into here. It's not really related

@ghsteff ghsteff requested a review from amcdnl March 14, 2024 17:02
@ghsteff ghsteff linked an issue Mar 14, 2024 that may be closed by this pull request
@amcdnl amcdnl merged commit e829468 into master Mar 14, 2024
1 check passed
@amcdnl amcdnl deleted the fix/zoom-to-cursor branch March 14, 2024 19:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Zoom to Cursor not working
2 participants